home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1994-09-02 | 3.8 KB | 175 lines | [ TEXT/MMCC]
/******************************************** **** ACL-World **** **** Controls.cp **** **** Created: 25 August 1994 **** Modified: 29 August 1994 **** Version: 0 **** Compatible: C++, Mac System 7 **** **** Description: Controls demo. **** *******************/ #include "ACL-World.h" //************************************* static const short PICT_BACKGROUND = 142; static const short PICT_BACKGROUND2 = 147; static const short PICT_BACKGROUND3 = 148; //************************************* #define TEXTSTEP1 "\pA control is a chain of commands which can be linked to any ACL moveable object. There are several different commands. Click in the picture to see a \"go to\" command." #define TEXTSTEP2 "\pACL defines also a \"curve\" command. Speed and acceleration may be defined for \"curve\" and \"go to\" commands. Click anywhere in this picture to see the curve path. The object will go through the center of the picture and accelerate to the spot you clicked." #define TEXTSTEP3 "\pCommands can be chained and a loop can be inserted in the chain. When a list of commands is linked to an object, ACL processes it automatically." #define TEXTSTEP4 "\pACL supports several commands which allow the user to build specific and complex command chains. An user method can be linked to each command in the chain allowing a dynamic execution of the controls." //************************************* static AnimGfx *background; static short backwidth,backheight; static Anim *anims[1]; static AnimControl controls[1]; //************************************* Boolean ACLWorld::controls_advance(void) { short i; Handle ha; Rect rect; static short w,h; step++; GetDItem(dialog,1,&i,&ha,&rect); switch(step) { case 1: SetIText(ha,TEXTSTEP1); animbase->installbackground(background); animbase->settupdate(1); anims[0] = animbase->createanim(animpers); anims[0]->setsequence(2); anims[0]->findmaxsize(&w,&h); anims[0]->arrange_moveframeoffsets(2, -(w/2),-(h/2)); anims[0]->place(140,90); controls[0].cmd = acmd_goto; controls[0].speed = 4; controls[0].acceleration = 0; controls[0].next = NULL; return FALSE; case 2: SetIText(ha,TEXTSTEP2); anims[0]->stopcontrol(); controls[0].cmd = acmd_curve; controls[0].cx = backwidth/2; controls[0].cy = backheight/2; return FALSE; case 3: SetIText(ha,TEXTSTEP3); delete anims[0]; animbase->installbackground(PICT_BACKGROUND2); return FALSE; case 4: SetIText(ha,TEXTSTEP4); animbase->installbackground(PICT_BACKGROUND3); return FALSE; } return TRUE; } //************************************* Boolean ACLWorld::do_controls(void) { Point p; char key; short res; Boolean done = FALSE; pleasewait(TRUE); animbase = new AnimBase(); background = animbase->newgfx(PICT_BACKGROUND); animbase->newgfx(PICT_BACKGROUND2); animbase->newgfx(PICT_BACKGROUND3); animbase->preload_framedef(animpers); backwidth = background->getwidth(); backheight = background->getheight(); animbase->buildbuffer(460,217); animbase->setbasex(17); animbase->setbasey(8); pleasewait(FALSE); step = 0; openbasedialog(); SetWTitle(dialog,"\pControls"); controls_advance(); for(;;) { res = processbasedialog(key,p); if (res==DO_QUIT) {done=TRUE; break;} else if (res==DO_MENU) break; else if (res==DO_CONTINUE && controls_advance()) break; else if (res==DO_MOUSECLICK && (step==1 || step==2)) { if (p.h<460 && p.v<217 && p.h>=0 && p.v>=0) { anims[0]->stopcontrol(); controls[0].x = p.h; controls[0].y = p.v; if (step==2) { controls[0].speed = 1; controls[0].acceleration = 0.25; } anims[0]->runcontrol(controls); } } } closebasedialog(); delete animbase; return done; } //*************************************